<template>
  <!-- svg组件 -->
  <svg
    class="svg-icon"
    :class="`svg-icon-${name}`"
    aria-hidden="true"
    v-on="$listeners"
  >
    <use :xlink:href="iconName" />
  </svg>
</template>

<script>
export default {
  name: "svg-icon",
  props: {
    name: {
      type: String,
      required: true
    }
  },
  computed: {
    iconName() {
      require(`@/assets/svg/${this.name}.svg`);
      return `#icon-${this.name}`;
    }
  }
};
</script>

<style>
.svg-icon {
  width: 25px;
  height: 25px;
  fill: currentColor;
  overflow: hidden;
}
</style>
